package com.timoon.component.panel.grid.actions;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;

import com.timoon.component.panel.grid.GridService;

/**
 *<p></p>
 *<p></p>
 *<p>Copyright:Copyright(c)2013.4.1</p>
 *<p>Company:timoon</p>
 *@author 付乐天
 *@version 1.0 */
public class SaveButton extends AjaxButton {

	private ModalWindow win;
	private GridService service;
	private TextField<String>[] texts;
	
	public SaveButton(String id,GridService service,ModalWindow window,TextField<String>...texts) {
		super(id);
		// TODO Auto-generated constructor stub
		this.win=window;
		this.service=service;
		this.texts=texts;
	}
	
	@Override
	protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
		// TODO Auto-generated method stub
		super.onSubmit(target, form);
		
		this.win.close(target);
		for(TextField<String> text:texts){
			System.out.println(text.getDefaultModelObjectAsString());
			text.clearInput();
		}
	}

}
